Skip to content

Added new spring-ai couchbase vector store tutorial#53

Merged
deniswsrosa merged 3 commits intomainfrom
spring-ai-tutorial
Apr 4, 2025
Merged

Added new spring-ai couchbase vector store tutorial#53
deniswsrosa merged 3 commits intomainfrom
spring-ai-tutorial

Conversation

@abhiraj2
Copy link
Copy Markdown
Contributor

@abhiraj2 abhiraj2 commented Apr 3, 2025

No description provided.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello @abhiraj2, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

Summary of Changes

This pull request adds a new tutorial on how to use Couchbase as a vector store with Spring AI. The tutorial provides a step-by-step guide on configuring and using Couchbase for vector search, including setting up the necessary components, loading data, and performing similarity searches. It also includes example source code and configuration details.

Highlights

  • New Tutorial: Adds a new tutorial on using Couchbase as a Spring AI embedding storage.
  • Example Code: Provides example source code for the tutorial, demonstrating how to integrate Couchbase with Spring AI.
  • Configuration Details: Includes detailed configuration instructions and code snippets for setting up the Couchbase vector store.
  • REST API Endpoints: Explains the REST API endpoints for loading data and performing similarity searches.

Changelog

  • tutorial/markdown/java/spring-ai.md
    • Added a new markdown file containing the tutorial content.
    • Included sections on Spring AI introduction, Couchbase embedding store setup, project structure, and configuration.
    • Provided code examples for configuring the Couchbase cluster, OpenAI embedding model, and Couchbase vector store.
    • Explained the vector store integration and the use of FTS vector index.
    • Documented the REST API endpoints for loading data and performing similarity searches.
    • Added instructions on how to use the application, including loading data and performing searches.
    • Included links to relevant resources such as Spring AI documentation, Couchbase Vector Search documentation, and OpenAI Embeddings documentation.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in issue comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist is currently in preview and may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments to provide feedback.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.


In realms of AI, a quest we find,
With vectors stored, of a searching kind.
Couchbase and Spring,
A knowledge they bring,
To make AI insights aligned.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request adds a new tutorial on using Couchbase Vector Search with Spring AI. The tutorial provides a good overview of how to configure and use Couchbase as a Spring AI embedding storage. The example code is helpful and the instructions are clear. However, there are a few areas that could be improved for clarity and completeness.

Summary of Findings

  • Completeness of Configuration Details: The tutorial mentions configuring the application in application.properties but doesn't explicitly state that the user needs to create this file if it doesn't exist. This could be confusing for new users.
  • Vector Index Configuration: The tutorial mentions that the store will attempt to create a new index with default configuration. It should emphasize the importance of reviewing and adjusting the index settings for specific use cases and provide more guidance on how to do this.
  • Incomplete Code Snippets: The tutorial includes incomplete code snippets (e.g., in the Load functionality section). These snippets should be complete or clearly indicate what is being omitted.

Merge Readiness

The tutorial provides valuable information on using Couchbase Vector Search with Spring AI. However, addressing the identified issues would enhance its clarity and completeness. I am unable to approve this pull request, and recommend that another reviewer does so. I recommend that the pull request not be merged until the identified issues are addressed.

Comment thread tutorial/markdown/java/spring-ai.md Outdated
Comment on lines +57 to +58
embeddings. Filtering selected by vector search embeddings by their metadata was not supported at the moment of writing
this tutorial.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

It might be helpful to mention that filtering by metadata is a planned feature or provide alternative strategies for achieving similar functionality if possible.

Comment on lines +84 to +85
The application is configured in `application.properties`:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Consider adding a note that if the application.properties file does not exist, the user needs to create it.

Comment on lines +162 to +164
configuration based on the provided initialization settings. It is recommended to manually review the settings for the
created index and adjust them according to specific use cases. More information about vector search and FTS index
configuration can be found at [Couchbase Documentation](https://docs.couchbase.com/server/current/vector-search/vector-search.html).
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Emphasize the importance of manually reviewing and adjusting the settings for the created index and provide more guidance on how to do this. Link to the relevant section in the Couchbase documentation.

Comment on lines +174 to +176
...
Document doc = new Document(String.format("%s", i + 1), j.getString("content"), Map.of("title", j.getString("title")))
...
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This code snippet is incomplete. Either provide the complete code or clearly indicate what is being omitted (e.g., using ellipsis with a comment).

@abhiraj2 abhiraj2 requested a review from deniswsrosa April 3, 2025 09:16
Copy link
Copy Markdown

@deniswsrosa deniswsrosa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are no instructions on how to run the app (always a good thing to add). Also, you need to include more links to documentation in general.

Comment thread tutorial/markdown/java/spring-ai.md Outdated
---

## About This Tutorial
This tutorial will show how to use a Couchbase database cluster as a Spring AI embedding storage.
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be nice to make this phrase a bit more engaging.


### What is Spring AI?

Spring AI is an extension of the Spring Framework that simplifies the integration of AI capabilities into Spring applications. It provides abstractions and integrations for working with various AI services and models, making it easier for developers to incorporate AI functionality without having to manage low-level implementation details.
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Link to the spring ai project

Comment thread tutorial/markdown/java/spring-ai.md
Comment thread tutorial/markdown/java/spring-ai.md Outdated
## Couchbase Embedding Store
Couchbase spring-ai integration stores each embedding in a separate document and uses an FTS vector index to perform
queries against stored vectors. Currently, it supports storing embeddings and their metadata, as well as removing
embeddings.
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This last phrase sounds a bit awkward. Is the framework supposed to support more things? After reading it, feels like there is something missing that we haven't implemented yet.

Comment thread tutorial/markdown/java/spring-ai.md Outdated

### Prerequisites
- [Couchbase Capella](https://docs.couchbase.com/cloud/get-started/create-account.html) account or locally installed [Couchbase Server](/tutorial-couchbase-installation-options)
- Java 21
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is java 21 a must? check the framework requirements. I think it has to be at least java 17.

Comment thread tutorial/markdown/java/spring-ai.md Outdated
- [Couchbase Capella](https://docs.couchbase.com/cloud/get-started/create-account.html) account or locally installed [Couchbase Server](/tutorial-couchbase-installation-options)
- Java 21
- Maven
- Couchbase Server running locally
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You don't need couchbase server running locally. Just add "Couchbase Server"

Comment thread tutorial/markdown/java/spring-ai.md

### Vector Store Integration

The application uses `CouchbaseSearchVectorStore`, which:
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Link to the JavaDocs of this class

@abhiraj2 abhiraj2 requested a review from deniswsrosa April 4, 2025 09:25
@deniswsrosa deniswsrosa marked this pull request as ready for review April 4, 2025 16:49
@deniswsrosa deniswsrosa requested a review from a team as a code owner April 4, 2025 16:49
@deniswsrosa deniswsrosa merged commit d5b1589 into main Apr 4, 2025
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants